package com.sky.mapper;

import com.sky.anotion.AutoFill;
import com.sky.anotion.AutoId;
import com.sky.dto.common.QueryParams;
import com.sky.entity.CompetionCategory;
import com.sky.enumeration.OperationType;
import com.sky.vo.CompetionCategoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CompetionCategoryMapper {

    /**
     * 获取所有竞赛分类数据
     * @return
     */
    List<CompetionCategory> getAllList(QueryParams params);

    /**
     * 新增竞赛分类
     * @param competionCategory
     */
    @AutoFill(OperationType.INSERT)
    @AutoId
    void addCompetionCategory(CompetionCategory competionCategory);

    /**
     * 删除竞赛分类
     * @param ids
     */
    void deleteByIds(List<String> ids);

    /**
     * 获取竞赛分类详情
     * @param id
     * @return
     */
    @Select("SELECT * FROM competition_category WHERE id = #{id}")
    CompetionCategoryVO getDetail(String id);
    /**
     * 修改竞赛分类
     */
    @AutoFill(OperationType.UPDATE)
    void update(CompetionCategory competionCategory);
    /**
     * 获取所有的共同含有的竞赛分类（所有部门参加的）
     */
    @Select("SELECT * FROM competition_category WHERE department_id = ''")
    List<CompetionCategory> getAllCompetitionCategory();

    /**
     * 根据id获取竞赛分类
     * @param id
     * @return
     */
    @Select("SELECT * FROM competition_category WHERE id = #{id}")
    CompetionCategory getById(String id);
    /**
     * 修改竞赛审批类型
     */
    @Update("UPDATE competition_category SET type = #{type} WHERE id = #{id}")
    void updateType(Integer type, String id);
}
